package org.dant.ant.extension.net;

import java.util.*;

import org.dant.ant.extension.tasks.commands.CommandsConstants;

public class CommandMap {

  protected static Map cmdMap = new HashMap();
  
  static {
    cmdMap.put(CommandsConstants.DANT_CMD_COPY, "org.dant.ant.extension.net.processors.CopyProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_PING, "org.dant.ant.extension.net.processors.PingProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_EXEC, "org.dant.ant.extension.net.processors.ExecProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_JAVA, "org.dant.ant.extension.net.processors.JavaProcessor");

    cmdMap.put(CommandsConstants.DANT_CMD_SHUTDOWN_EXEC, "org.dant.ant.extension.net.processors.ShutdownExecProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_SHUTDOWN_JAVA, "org.dant.ant.extension.net.processors.ShutdownJavaProcessor");
    
    cmdMap.put(CommandsConstants.DANT_CMD_ANT, "org.dant.ant.extension.net.processors.AntProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_ANT_CALL, "org.dant.ant.extension.net.processors.AntCallProcessor");

    cmdMap.put(CommandsConstants.DANT_CMD_MONITOR, "org.dant.ant.extension.net.processors.MonitorProcessor");
    cmdMap.put(CommandsConstants.DANT_CMD_SYSINFO, "org.dant.ant.extension.net.processors.SysInfoProcessor");
  }

  public static String getProcessorName(String key) {
    return (String) cmdMap.get(key);
  }

  public static Class getProcessorClz(String clz) throws ClassNotFoundException {
    String clzName = (String)cmdMap.get(clz);
    if (clzName == null) throw new ClassNotFoundException("Required command  <" + clz + "> is not exist in the Commands Map");
    return Class.forName(clzName);
  }
}
